var modContextMenuSample_locLang=new localLang("modContextMenuSample");
var modContextMenuSample= new Class({
    Extends:WFWindow,
    sampleProxyEnable: true,
    options: {
        name: 'modContextMenuSample',
        title: modContextMenuSample_locLang.label('title'),
        btnSettings: true,
        btnRefresh: true,
        btnHelp: true,
        btnClose: true,
        loadCSS: true,
        supportServerTypes:['modSimple'],
        defaultWidgetHeight: 244
    },
    renderContent: function(){
        var wid = this.id;
	    this.pane = new Element('div',{'class':'pane-grid'}).inject(this.boxBD);
	    this.contextMenu = new Element('div',{'id':'myMenu_'+wid,'class':'top-menu'}).inject(this.pane);
        this.grid = new Element('div',{'id':'myGrid_'+wid,'class':'trend-grid'}).inject(this.pane);

        var data = [],
            CLIENT_MENU = {
                buttonMode: true,
                theme: 'osce-button',
                menu: [
                    {
                        TEXT: 'Status',
                        GROUP: 0,
                        ONCLICK: function(e) {
                            alert('pop out ' + e.TEXT + ' page.');
                        }
                    },
                    {
                        TEXT: 'Tasks',
                        GROUP: 0,
                        CHILD: [
                            {
                                TEXT: 'Scan Now',
                                GROUP: 0
                            },
                            {
                                TEXT: 'Client Uninstallation',
                                GROUP: 0,
                                VISIBLE: false},
                            {
                                TEXT: 'Spyware/Grayware Restore',
                                GROUP: 1
                            }
                        ]
                    },
                {
                    TEXT: 'Settings',
                    GROUP: 0,
                    CHILD: [
                        {
                        TEXT: 'Scan Settings',
                        GROUP: 0,
                        CHILD: [
                            {
                            TEXT: 'Scan Methods',
                            GROUP: 0},
                        {
                            TEXT: 'Manual Scan Settings',
                            GROUP: 1},
                        {
                            TEXT: 'Real-time Scan Settings',
                            GROUP: 1},
                        {
                            TEXT: 'Scheduled Scan Settings',
                            GROUP: 1}
                        ]},
                    {
                        TEXT: 'Web Reputation Settings',
                        GROUP: 1},
                    {
                        TEXT: 'Behavior Monitoring Settings',
                        GROUP: 2},
                    {
                        TEXT: 'Device Control Settings',
                        GROUP: 2},
                    {
                        TEXT: 'Data Protection Settings',
                        GROUP: 2},
                    {
                        TEXT: 'Update Agent Settings',
                        GROUP: 3},
                    {
                        TEXT: 'Privileges and Other Settings',
                        GROUP: 3},
                    {
                        TEXT: 'Additional Service Settings',
                        GROUP: 4},
                    {
                        TEXT: 'Spyware/Grayware Approved List',
                        GROUP: 5},
                    {
                        TEXT: 'Export Settings',
                        GROUP: 6},
                    {
                        TEXT: 'Import Settings',
                        GROUP: 6},
                    {
                        TEXT: '[My test]',
                        GROUP: 7,
                        CHILD: [
                            {
                            TEXT: 'Scan Settings',
                            GROUP: 0,
                            CHILD: [
                                {
                                TEXT: 'Scan Methods',
                                GROUP: 0},
                            {
                                TEXT: 'Manual Scan Settings',
                                GROUP: 1},
                            {
                                TEXT: 'Real-time Scan Settings',
                                GROUP: 1},
                            {
                                TEXT: 'Scheduled Scan Settings',
                                GROUP: 1}
                            ]},
                        {
                            TEXT: 'Web Reputation Settings',
                            GROUP: 1},
                        {
                            TEXT: 'Behavior Monitoring Settings',
                            GROUP: 2},
                        {
                            TEXT: 'Device Control Settings',
                            GROUP: 2},
                        {
                            TEXT: 'Data Protection Settings',
                            GROUP: 2},
                        {
                            TEXT: 'Update Agent Settings',
                            GROUP: 3},
                        {
                            TEXT: 'Privileges and Other Settings',
                            GROUP: 3},
                        {
                            TEXT: 'Additional Service Settings',
                            GROUP: 4},
                        {
                            TEXT: 'Spyware/Grayware Approved List',
                            GROUP: 5},
                        {
                            TEXT: 'Export Settings',
                            GROUP: 6},
                        {
                            TEXT: 'Import Settings',
                            GROUP: 6}
                        ]}
                    ]},
                {
                    TEXT: 'Logs',
                    GROUP: 0,
                    CHILD: [
                        {
                        TEXT: 'Virus/Malware Logs',
                        GROUP: 0},
                    {
                        TEXT: 'Spyware/Grayware Logs',
                        GROUP: 0},
                    {
                        TEXT: 'Firewall Logs',
                        GROUP: 0},
                    {
                        TEXT: 'Web Reputation Logs',
                        GROUP: 0},
                    {
                        TEXT: 'Behavior Monitoring Logs',
                        GROUP: 1},
                    {
                        Text: 'Device Control Logs',
                        GROUP: 1},
                    {
                        TEXT: 'Data Protection Logs',
                        GROUP: 1},
                    {
                        TEXT: 'Delete Logs',
                        GROUP: 2}
                    ]},
                {
                    TEXT: 'Manage Client Tree',
                    GROUP: 0,
                    CHILD: [
                        {
                        TEXT: 'Add Domain',
                        GROUP: 0},
                    {
                        TEXT: 'Move Client',
                        GROUP: 0},
                    {
                        TEXT: 'Remove Domain/Client',
                        GROUP: 1}
                    ]},
                {
                    TEXT: 'Export',
                    GROUP: 0
                    }
                ]
            },
            CLIENT_MENU2 = {
                theme: 'osce',
                menu: [
                    {
                    TEXT: 'Status',
                    GROUP: 0,
                    ONCLICK: function(e) {
                        alert('pop out ' + e.data.target.TEXT + ' page.');
                    }},
                {
                    TEXT: 'Tasks',
                    GROUP: 0,
                    CHILD: [
                        {
                        TEXT: 'Scan Now',
                        GROUP: 0},
                    {
                        TEXT: 'Client Uninstallation',
                        GROUP: 0,
                        VISIBLE: false},
                    {
                        TEXT: 'Spyware/Grayware Restore',
                        GROUP: 1}
                    ]},
                {
                    TEXT: 'Settings',
                    GROUP: 0,
                    CHILD: [
                        {
                        TEXT: 'Scan Settings',
                        GROUP: 0,
                        CHILD: [
                            {
                            TEXT: 'Scan Methods',
                            GROUP: 0},
                        {
                            TEXT: 'Manual Scan Settings',
                            GROUP: 1},
                        {
                            TEXT: 'Real-time Scan Settings',
                            GROUP: 1},
                        {
                            TEXT: 'Scheduled Scan Settings',
                            GROUP: 1}
                        ]},
                    {
                        TEXT: 'Web Reputation Settings',
                        GROUP: 1},
                    {
                        TEXT: 'Behavior Monitoring Settings',
                        GROUP: 2},
                    {
                        TEXT: 'Device Control Settings',
                        GROUP: 2},
                    {
                        TEXT: 'Data Protection Settings',
                        GROUP: 2},
                    {
                        TEXT: 'Update Agent Settings',
                        GROUP: 3},
                    {
                        TEXT: 'Privileges and Other Settings',
                        GROUP: 3},
                    {
                        TEXT: 'Additional Service Settings',
                        GROUP: 4},
                    {
                        TEXT: 'Spyware/Grayware Approved List',
                        GROUP: 5},
                    {
                        TEXT: 'Export Settings',
                        GROUP: 6},
                    {
                        TEXT: 'Import Settings',
                        GROUP: 6},
                    {
                        TEXT: '[My test]',
                        GROUP: 7,
                        CHILD: [
                            {
                            TEXT: 'Scan Settings',
                            GROUP: 0,
                            CHILD: [
                                {
                                TEXT: 'Scan Methods',
                                GROUP: 0},
                            {
                                TEXT: 'Manual Scan Settings',
                                GROUP: 1},
                            {
                                TEXT: 'Real-time Scan Settings',
                                GROUP: 1},
                            {
                                TEXT: 'Scheduled Scan Settings',
                                GROUP: 1}
                            ]},
                        {
                            TEXT: 'Web Reputation Settings',
                            GROUP: 1},
                        {
                            TEXT: 'Behavior Monitoring Settings',
                            GROUP: 2},
                        {
                            TEXT: 'Device Control Settings',
                            GROUP: 2},
                        {
                            TEXT: 'Data Protection Settings',
                            GROUP: 2},
                        {
                            TEXT: 'Update Agent Settings',
                            GROUP: 3},
                        {
                            TEXT: 'Privileges and Other Settings',
                            GROUP: 3},
                        {
                            TEXT: 'Additional Service Settings',
                            GROUP: 4},
                        {
                            TEXT: 'Spyware/Grayware Approved List',
                            GROUP: 5},
                        {
                            TEXT: 'Export Settings',
                            GROUP: 6},
                        {
                            TEXT: 'Import Settings',
                            GROUP: 6}
                        ]}
                    ]},
                {
                    TEXT: 'Logs',
                    GROUP: 0,
                    CHILD: [
                        {
                        TEXT: 'Virus/Malware Logs',
                        GROUP: 0},
                    {
                        TEXT: 'Spyware/Grayware Logs',
                        GROUP: 0},
                    {
                        TEXT: 'Firewall Logs',
                        GROUP: 0},
                    {
                        TEXT: 'Web Reputation Logs',
                        GROUP: 0},
                    {
                        TEXT: 'Behavior Monitoring Logs',
                        GROUP: 1},
                    {
                        Text: 'Device Control Logs',
                        GROUP: 1},
                    {
                        TEXT: 'Data Protection Logs',
                        GROUP: 1},
                    {
                        TEXT: 'Delete Logs',
                        GROUP: 2}
                    ]},
                {
                    TEXT: 'Manage Client Tree',
                    GROUP: 0,
                    CHILD: [
                        {
                        TEXT: 'Add Domain',
                        GROUP: 0},
                    {
                        TEXT: 'Move Client',
                        GROUP: 0},
                    {
                        TEXT: 'Remove Domain/Client',
                        GROUP: 1}
                    ]},
                {
                    TEXT: 'Export',
                    GROUP: 0
                    }
                ]
            },
            i;
        for (i = 0; i < 50000; i++) {
            data.push({
                NAME: '(01)1_C' + i,
                IP: '174.184.227.166',
                GUID: '22220000-0000-0000-0000-00000000000' + i,
                CONNETCIONS: 'online'
            });
        }

        (function($) {
            $(function() {
                $('#myGrid_'+wid).trendGrid({
                    columns: [
                        {
                        id: "NAME",
                        name: 'Name',
                        width: 180,
                        sortAsc: true},
                    {
                        id: "IP",
                        name: "IP Address",
                        width: 140},
                    {
                        id: "CONNETCIONS",
                        name: "Connection",
                        width: 100},
                    {
                        id: "GUID",
                        name: "GUID",
                        width: 300}
                    ],
                    data: data,
                    rowRecords: 50000
                });
                $('#myMenu_'+wid).contextMenu(CLIENT_MENU);
            });
        })(jQuery);
	  
        window.fireEvent('widget_load', this.widgetInfo);	  
    },
	onClickRefresh2: function(){
	},
    displayChart:function(){
    },
    displaySuccess: function(response){
    },
    displayFailure: function(){
    },
    onContentresize: function(event){
    },
    refreshMod:function(){
    }
});
